<template>
	<div>
		<AplidForm v-bind="formConfig" v-model="searchModel" @reset="onReset" @submit="onSearch"></AplidForm>
    <ReportPreview ref="reportEl"></ReportPreview>
	</div>
</template>

<script setup lang="ts">
import ReportPreview from '@/views/aplid/ReportView/index.vue'
import apiMod from '@/apiMod'

const props = defineProps<{
  templateId?: string|number
}>()

const activeName = ref('')
const reportEl = ref(null)

const searchModel = ref({})
const formConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '统计时间',
			prop: 'timeBetween',
			type: 'dateBetween',
			span: 8,
		},
		{
			label: '统计地区',
			prop: 'areas',
			type: 'DateBetween',
			span: 8,
		},
	],
}

const onReset = () => {
	searchModel.value = {}
}

const onSearch = (search, done) => {
	getInitData()
	done()
}

const getInitData = ()=> {
  apiMod.view_tableTemplate_getData({
    ...searchModel.value,
    id:props.templateId,
  }).then(res=> {
    const option = res.data
    reportEl.value?.initData(option)
  })
}

onMounted(()=> {
  if(!props.templateId) {
    return false
  }
  getInitData()
})
</script>

<style scoped></style>
